import { Body, Controller, Get, HttpException, HttpStatus, Post, Res, UseInterceptors } from '@nestjs/common';
import { Response } from 'express';
import { InternetCelebrityGroupRelaIcInfoService } from './internetCelebrityGroupRelaIcInfo.service';
import { InternetCelebrityGroupRelaIcInfo } from './internetCelebrityGroupRelaIcInfo.entity';
import { apibefore } from 'src/router';
import { ValidUniqueLoginInterceptor } from 'src/interceptor/validUniqueLogin';


@Controller(apibefore('/internetCelebrityGroupRelaIcInfo'))
export class InternetCelebrityGroupRelaIcInfoController {
  constructor(private readonly internetCelebrityGroupRelaIcInfoService: InternetCelebrityGroupRelaIcInfoService) {}

  @Post('/create')
  @UseInterceptors(ValidUniqueLoginInterceptor)
  async create(@Body() params: InternetCelebrityGroupRelaIcInfo) {
    let data = new InternetCelebrityGroupRelaIcInfo();
    data.ic_group = params.ic_group
    data.ic_group_rela_ic_info = params.ic_group_rela_ic_info
    data.create_time = new Date()
    try{
      return await this.internetCelebrityGroupRelaIcInfoService.create(data);
    }catch(err) {
      return new HttpException(err, HttpStatus.INTERNAL_SERVER_ERROR)
    }
  }

  @Post('/remove')
  @UseInterceptors(ValidUniqueLoginInterceptor)
  async remove(@Body() params: InternetCelebrityGroupRelaIcInfo) {
    return await this.internetCelebrityGroupRelaIcInfoService.remove(params.id);
  }

  @Get('/findAll')
  async findAll(){
    return await this.internetCelebrityGroupRelaIcInfoService.findAll()
  }
}
